package cn.ichiva.dl.tushare.analy.impl;

import cn.ichiva.dl.tushare.analy.AgentConfig2442;
import cn.ichiva.dl.tushare.common.AgentConfig;
import cn.ichiva.dl.tushare.analy.AgentList;
import org.nd4j.linalg.api.ndarray.INDArray;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class TradeAgentList extends AgentList<TradeAgent> {

    public TradeAgentList(Collection<TradeAgent> list) {
        super(list);
    }

    public TradeAgentList(int max) {
        super(init(max));
    }

    public static ArrayList<TradeAgent> init(int max){
        ArrayList<TradeAgent> list = new ArrayList<>();
        for (int i = 0; i < max; i++) {
            list.add(new TradeAgent(AgentConfig2442.getInstance()));
        }
        return list;
    }

    @Override
    protected double getScore(TradeAgent agent) {
        List<Double> scores = agent.getScores();
        double x = Math.abs(scores.get(0) - scores.get(1)) * 5;
        double y = scores.get(0) + scores.get(1) - agent.getTrade().getInitMoney() * 2;
        return y - x;
    }

    @Override
    protected TradeAgent createAgent(AgentConfig config, INDArray dna) {
        return new TradeAgent(config,dna);
    }
}
